// types.ts
export interface FileInfo {
    name: string;
    size: number;
    mime: string;
}

export interface MessagePeer {
    sender: string | null;
    receiver: string | null;
    group_code: string | null;
    notice_type: number;
    files: FileInfo[];
}

export interface UnpackedMessage {
    type: number;
    sn: string;
    index: number;
    count: number;
    noticeType: number | null;
    sender: string | null;
    receiver: string | null;
    groupCode: string | null;
    files: FileInfo[];
    payload: Uint8Array;
}

export interface FragmentCache {
    chunks: Map<number, Uint8Array>;
    total: number;
    peer: Partial<MessagePeer>;
    type: number;
}

export interface ProcessedMessage extends Omit<UnpackedMessage, 'payload'> {
    payload: string | Blob | Uint8Array;
    files: FileInfo[];
}

export type MessageCallback = (msg: ProcessedMessage) => void;
export type ProgressCallback = (current: number, total: number) => void;